﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ImportExcel.aspx.cs" Inherits="FBKPI.Tools.ImportExcel.ImportExcel" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Import</title>
    <script src="../../Scripts/jquery-1.8.2.min.js" type="text/javascript"></script>
    <script src="../../Scripts/jquery-ui-1.8.23.min.js" type="text/javascript"></script>
    <link href="../../Styles/style.css" rel="Stylesheet" type="text/css" />

    <script type="text/javascript">
        $(document).ready(function () {
            $("#lnk_download").live("click", function () {
                var importMode = $("#txt_mode").val();
                if (importMode.toString().indexOf("employee") >= 0) {
                    $.ajax({
                        url: '../../Tools/ImportExcel/Handler/DownloadTemplateHandler.ashx?modul=employee',
                        type: "POST",
                        success: function (data) {
                            document.location = data;
                            return false;
                        },
                        error: function (data) {
                            alert("Error while downloading employee template file, please contact IT support");
                            return false;
                        }
                    });
                    return false;
                }
                else if (importMode.toString().indexOf("kpi") >= 0) {
                    $.ajax({
                        url: '../../Tools/ImportExcel/Handler/DownloadTemplateHandler.ashx?modul=kpi',
                        type: "POST",
                        success: function (data) {
                            document.location = data;
                            return false;
                        },
                        error: function (data) {
                            alert("Error while downloading kpi template file, please contact IT support");
                            return false;
                        }
                    });
                    return false;
                }
            });
        })
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <div id="importexcelformarea" class="ui-widget-content padding5px ui-corner-all">
            <table class="dialogTable">
                <tr>
                    <td width="100px">Select File</td>
                    <td>:</td>
                    <td><asp:FileUpload ID="upload" runat="server" /></td>
                </tr>
                <tr>
                    <td>Result</td>
                    <td>:</td>
                    <td><asp:Label ID="lbl_result" runat="server"></asp:Label><input type="hidden" id="uploadpath" runat="server" /><input type="hidden" runat="server" id="txt_mode"></td>
                </tr>
            </table>
            <br />
        </div>
        <br />
        <div>
            <asp:Button runat="server" ID="btn_upl" Text="Upload" onclick="btn_upl_Click" />&nbsp;<asp:Button 
                runat="server" ID="btn_import" Text="Import" onclick="btn_import_Click"/>&nbsp;<a href="#" id="lnk_download">download template</a>
        </div>
    </form>
</body>
</html>
